package com.example.rabbitmqbootconsumer.receiver.direct;

import com.example.rabbitmqbootconsumer.dto.MessageDTO;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import static com.example.rabbitmqbootconsumer.constant.MessageConstant.DIRECT_QUEUE_NAME;

/**
 * 接收直连消息
 *
 * @author 伯路平
 * @since 2023/6/19
 **/
@Component
@Slf4j
//@RabbitListener(queues = DIRECT_QUEUE_NAME)
public class DirectReceiver3 {
    private static final Gson GSON = new Gson();

    @RabbitHandler
    public void process(String message) {
        MessageDTO messageDTO = GSON.fromJson(message, MessageDTO.class);
        log.info("3号消费者监听队列接收到直连消息:{}", messageDTO);
    }
}
